﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 建邦配料系统
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }
        static String connetStr = "server=127.0.0.1;port=3306;user=root;password=952716; database=MySQL";
        //usr:用户名，password：数据库密码，database：数据库名
        MySqlConnection conn = new MySqlConnection(connetStr);

        private void Login_Load(object sender, EventArgs e)
        {
            textBox1.Text = Properties.Settings.Default.账号;
            textBox2.Text= Properties.Settings.Default.密码;
        }

        public bool MainClose;
        private void button2_Click(object sender, EventArgs e)
        {
            //using (MySqlConnection conn = new MySqlConnection(connetStr))
            //{
            //    string sql = "select * from ingredientDB.loginmanagement where UserName= '" + textBox1.Text + "';";
            //    conn.Open();
            //    MySqlCommand cmd = new MySqlCommand(sql, conn);
            //    MySqlDataReader reader = cmd.ExecuteReader();//执行ExecuteReader()返回一个MySqlDataReader对象
            //    while (reader.Read())
            //    {
            //        if (textBox2.Text == reader.GetString("Password"))
            //        {
            //            MainClose = true;

            //           this.Close();
            //            return;
            //        }
            //    }
            //    MessageBox.Show("用户名不存在或密码错误！");
            //}
            if(textBox1.Text=="admin")
            {
                if(textBox2.Text =="FJSDYY")
                {

                    this.Close();
                    //return;

                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Login_FormClosed(object sender, FormClosedEventArgs e)
        {
            Properties.Settings.Default.账号 = textBox1.Text;
            Properties.Settings.Default.密码 = textBox2.Text;
            Properties.Settings.Default.Save();
        }
    }
}
